package fei.typhoon.engine.utils;

/**
 * @author fei.typhoon 此类中的属性只能被设置一次
 */
public class FeiUtils {
	/** 标准屏幕尺寸较长边，默认为800 */
	private int debugScreenLongSide = 800;
	/** 标准屏幕尺寸较短边，默认为480 */
	private int debugScreenShortSide = 480;
	/** 屏幕宽 */
	private int screenWidth = 480;
	/** 屏幕高 */
	private int screenHeight = 800;
	/** X方向的缩放倍率 */
	private float scaleX = 1.0f;
	/** Y方向的缩放倍率 */
	private float scaleY = 1.0f;
	/** X与Y方向的统一缩放倍率，实际=min(scaleX,scaleY) */
	private float scale = 1.0f;
	/** 缩放图片是否保持图片宽高比 */
	private boolean keepProportion = true;
	/** 自适应屏幕尺寸是否采取图片真缩放 */
	private boolean bitmapZoomReally = false;
	/** keepProportion为true时，本字段有效。true表示图片缩放比例等于X或Y方向缩放比例大者 */
	private boolean bitmapZoomLarge = false;
	/** 屏幕是否是恒定竖屏 */
	private boolean screenOrientationPortrait = true;
	/** 是否自动适配屏幕 */
	private boolean screenAutoAdapt = true;
	/** 仅仅用于记录screenOrientationPortrait是否被设置过 */
	private boolean hasSetOrientation = false;
	/** 仅仅用于记录screenAutoAdapt是否被设置过 */
	private boolean hasSetAutoAdapt = false;
	/** 仅仅用于记录debugScreenLongSide是否被设置过 */
	private boolean hasSetDebugLong = false;
	/** 仅仅用于记录debugScreenShortSide是否被设置过 */
	private boolean hasSetDebugShort = false;
	/** 仅仅用于记录bitmapZoomLarge是否被设置过 */
	private boolean hasSetZoomLarge = false;
	/** 仅仅用于记录keepProportion是否被设置过 */
	private boolean hasSetKeepProportion = false;
	/** 仅仅用于记录bitmapZoomReally是否被设置过 */
	private boolean hasSetZoomReally = false;
	/** 仅仅用于记录screenWidth是否被设置过 */
	private boolean hasSetScreenWidth = false;
	/** 仅仅用于记录screenHeight是否被设置过 */
	private boolean hasSetScreenHeight = false;
	/** 仅仅用于记录scaleX是否被设置过 */
	private boolean hasSetScaleX = false;
	/** 仅仅用于记录scaleY是否被设置过 */
	private boolean hasSetScaleY = false;
	/** 仅仅用于记录scale是否被设置过 */
	private boolean hasSetScale = false;

	public FeiUtils() {
		debugScreenLongSide = 800;
		debugScreenShortSide = 480;
		screenWidth = 480;
		screenHeight = 800;
		scaleX = 1.0f;
		scaleY = 1.0f;
		scale = 1.0f;
		keepProportion = true;
		bitmapZoomReally = false;
		bitmapZoomLarge = false;
		screenOrientationPortrait = true;
		screenAutoAdapt = true;
		hasSetOrientation = false;
		hasSetAutoAdapt = false;
		hasSetDebugLong = false;
		hasSetDebugShort = false;
		hasSetZoomLarge = false;
		hasSetKeepProportion = false;
		hasSetZoomReally = false;
		hasSetScreenWidth = false;
		hasSetScreenHeight = false;
		hasSetScaleX = false;
		hasSetScaleY = false;
		hasSetScale = false;
	}

	public boolean isScreenOrientationPortrait() {
		return screenOrientationPortrait;
	}

	/**
	 * 屏幕是否是恒定竖屏，false恒定横屏
	 * 
	 * @param screenOrientationPortrait
	 */
	public void setScreenOrientationPortrait(boolean screenOrientationPortrait) {
		if (!hasSetOrientation) {
			hasSetOrientation = true;
			this.screenOrientationPortrait = screenOrientationPortrait;
		}
	}

	public boolean isScreenAutoAdapt() {
		return screenAutoAdapt;
	}

	/**
	 * 是否自动适配屏幕
	 */
	public void setScreenAutoAdapt(boolean screenAutoAdapt) {
		if (!hasSetAutoAdapt) {
			hasSetAutoAdapt = true;
			this.screenAutoAdapt = screenAutoAdapt;
			if (!this.screenAutoAdapt) {
				scaleX = 1.0f;
				scaleY = 1.0f;
				scale = 1.0f;
			}
		}
	}

	public int getDebugScreenLongSide() {
		return debugScreenLongSide;
	}

	public void setDebugScreenLongSide(int debugScreenLongSide) {
		if (!hasSetDebugLong) {
			hasSetDebugLong = true;
			this.debugScreenLongSide = debugScreenLongSide;
		}
	}

	public int getDebugScreenShortSide() {
		return debugScreenShortSide;
	}

	public void setDebugScreenShortSide(int debugScreenShortSide) {
		if (!hasSetDebugShort) {
			hasSetDebugShort = true;
			this.debugScreenShortSide = debugScreenShortSide;
		}
	}

	public boolean isBitmapZoomLarge() {
		return bitmapZoomLarge;
	}

	/**
	 * keepProportion为true时，bitmapZoomLarge字段有效。true表示图片缩放比例等于X或Y方向缩放比例大者
	 */
	public void setBitmapZoomLarge(boolean bitmapZoomLarge) {
		if (!hasSetZoomLarge) {
			hasSetZoomLarge = true;
			this.bitmapZoomLarge = bitmapZoomLarge;
		}
	}

	public boolean isKeepProportion() {
		return keepProportion;
	}

	/**
	 * 缩放图片是否保持图片宽高比
	 */
	public void setKeepProportion(boolean keepProportion) {
		if (!hasSetKeepProportion) {
			hasSetKeepProportion = true;
			this.keepProportion = keepProportion;
		}
	}

	public boolean isBitmapZoomReally() {
		return bitmapZoomReally;
	}

	/**
	 * 自适应屏幕尺寸是否采取图片真缩放
	 */
	public void setBitmapZoomReally(boolean bitmapZoomReally) {
		if (!hasSetZoomReally) {
			hasSetZoomReally = true;
			this.bitmapZoomReally = bitmapZoomReally;
		}
	}

	public int getScreenWidth() {
		return screenWidth;
	}

	public void setScreenWidth(int screenWidth) {
		if (!hasSetScreenWidth) {
			hasSetScreenWidth = true;
			this.screenWidth = screenWidth;
		}
	}

	public int getScreenHeight() {
		return screenHeight;
	}

	public void setScreenHeight(int screenHeight) {
		if (!hasSetScreenHeight) {
			hasSetScreenHeight = true;
			this.screenHeight = screenHeight;
		}
	}

	public float getScaleX() {
		return scaleX;
	}

	public void setScaleX(float scaleX) {
		if (!hasSetScaleX) {
			hasSetScaleX = true;
			this.scaleX = scaleX;
		}
	}

	public float getScaleY() {
		return scaleY;
	}

	public void setScaleY(float scaleY) {
		if (!hasSetScaleY) {
			hasSetScaleY = true;
			this.scaleY = scaleY;
		}
	}

	public float getScale() {
		return scale;
	}

	public void setScale(float scale) {
		if (!hasSetScale) {
			hasSetScale = true;
			this.scale = scale;
		}
	}

}
